package com.pvms.demo;

import com.influxdb.client.InfluxDBClient;
import com.influxdb.client.InfluxDBClientFactory;
import com.influxdb.client.WriteApiBlocking;
import com.influxdb.client.domain.WritePrecision;
import com.influxdb.client.write.Point;

import java.time.Instant;

/**
 * @author :吴申
 * @since :2025/5/15 10:24
 */

//采用influxdb时序数据库写入数据
//第二题没时间写了，只写了大概的demo
public class Write1 {
    private static char[] token = "uzTPRDFYgPZU_jSYnvYaiNuaqTiOStX2mWjtModA_qKFI0H_Cqai5E08QiR_TKkiW1VFXHj_pnTOBw4ZvMbK1Q==".toCharArray();
    private static String org = "huadian";
    private static String bucket = "example_java";
    private static String url = "http://60.205.228.172:8086/";


    public static void main(String[] args) {
        InfluxDBClient influxDBClient = InfluxDBClientFactory.create(url, token, org, bucket);
        WriteApiBlocking writeApiBlocking = influxDBClient.getWriteApiBlocking();
        Temperature temperature = new Temperature("east", 59.1, Instant.now());
        writeApiBlocking.writeMeasurement(WritePrecision.MS, temperature);


        influxDBClient.close();
    }
}
